package cn.sunshine.system.service.impl;

import cn.sunshine.basic.service.impl.BaseServiceImpl;
import cn.sunshine.system.domain.DictionaryType;
import cn.sunshine.system.mapper.DictionaryDetailMapper;
import cn.sunshine.system.mapper.DictionaryTypeMapper;
import cn.sunshine.system.service.IDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
// 只读事务
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class DictionaryTypeServiceImpl extends BaseServiceImpl<DictionaryType> implements IDictionaryTypeService {
    @Autowired
    private DictionaryTypeMapper dictionaryTypeMapper;
    @Autowired
    private DictionaryDetailMapper dictionaryDetailMapper;
    @Override
    public void remove(Long id) {
      List<Long> list = new ArrayList<>();
      list.add(id);
        dictionaryDetailMapper.removeTyId(list);
        super.remove(id);
    }

    @Override
    public void batchRemove(List<Long> ids) {
        dictionaryDetailMapper.removeTyId(ids);
        super.batchRemove(ids);
    }
}
